package com.room.search.job.processor;

import com.room.search.service.RoomSearchGoodService;
import org.springframework.stereotype.Component;
import tech.powerjob.worker.core.processor.ProcessResult;
import tech.powerjob.worker.core.processor.TaskContext;
import tech.powerjob.worker.core.processor.sdk.BasicProcessor;

/**
 * By   : ghd.bright
 * Time : 2022/5/5
 * Description: 定时去更新Elastic的数据
 */
@Component
public class UpdateElasticSearchDataProcessor implements BasicProcessor {

    private final RoomSearchGoodService roomSearchGoodService;

    public UpdateElasticSearchDataProcessor(RoomSearchGoodService roomSearchGoodService) {
        this.roomSearchGoodService = roomSearchGoodService;
    }


    @Override
    public ProcessResult process(TaskContext context) throws Exception {
        roomSearchGoodService.updateAll();
        ProcessResult processResult = new ProcessResult();
        processResult.setSuccess(true);
        return processResult;
    }
}
